<%@ page language="java" contentType="text/html; charset=utf-8"	pageEncoding="utf-8"%>
<%@ include file="../../common/tag.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<LINK href="../resource/css/frame.css" type="text/css" rel="stylesheet">
	<link rel="stylesheet" href="<%=basePath %>/resource/css/demo.css" type="text/css">
	<link rel="stylesheet" href="<%=basePath %>/resource/css/zTreeStyle.css" type="text/css">
	<script type="text/javascript" src="<%=basePath %>/resource/js/jquery-1.4.4.min.js"></script>
	<script type="text/javascript" src="<%=basePath %>/resource/js/jquery.ztree.core-3.2.js"></script>
<SCRIPT type="text/javascript">
		<!--
		var curMenu = null, zTree_Menu = null;
		var setting = {
				data: {
					simpleData: {
						enable: true
					}
				}
			};

		function beforeClick(treeId, node) {
			if (node.isParent) {
				if (node.level === 0) {
					var pNode = curMenu;
					while (pNode && pNode.level !==0) {
						pNode = pNode.getParentNode();
					}
					if (pNode !== node) {
						var a = $("#" + pNode.tId + "_a");
						a.removeClass("cur");
						zTree_Menu.expandNode(pNode, false);
					}
					a = $("#" + node.tId + "_a");
					a.addClass("cur");

					var isOpen = false;
					for (var i=0,l=node.children.length; i<l; i++) {
						if(node.children[i].open) {
							isOpen = true;
							break;
						}
					}
					if (isOpen) {
						zTree_Menu.expandNode(node, true);
						curMenu = node;
					} else {
						zTree_Menu.expandNode(node.children[0].isParent?node.children[0]:node, true);
						curMenu = node.children[0];
					}
				} else {
					zTree_Menu.expandNode(node);
				}
			}
			return !node.isParent;
		}
		function onClick(e, treeId, node) {
			alert("Do what you want to do!");
		}

		$(document).ready(function(){
			$.ajax({
				url:"../menu/queryAuthMenu.action",
				type:"GET",
				cache:false,
				async:false,
				error:function(json){
					 alert('Error loading XML document');
			         return false;
				},
				success:function(json){
					$.fn.zTree.init($("#treeDemo"), setting, eval(json.menuTree));
				}
			});
			zTree_Menu = $.fn.zTree.getZTreeObj("treeDemo");
			curMenu = zTree_Menu.getNodes()[0].children[0].children[0];
			zTree_Menu.selectNode(curMenu);
			var a = $("#" + zTree_Menu.getNodes()[0].tId + "_a");
			a.addClass("cur");
		});
		//-->
	</SCRIPT>
	<style type="text/css">
	.ztree li a.level0 {width:170px;height: 20px; text-align: center; display:block; background-color: #0B61A4;}
	.ztree li a.level0.cur {background-color: #66A3D2; }
	.ztree li a.level0 span {display: block; color: white; padding-top:3px; font-size:12px; font-weight: bold;word-spacing: 2px;}
	.ztree li a.level0 span.button {visibility: visible;display:none;}
	.ztree li span.button.switch.level0 {display:none;}
	</style>
 </HEAD>

<BODY>
	<div class="zTreeDemoBackground left">
		<ul id="treeDemo" class="ztree"></ul>
	</div>
</BODY>
</HTML>